var md5   = require('md5.js')
function sign(data,key) {
  var str = '';
  var arr = [];
  for(var item in data){
    if (item != 'sign') {
      arr.push([item,data[item]]);
    }
  }
  arr.sort(function(x,y){return x[0]>y[0] || -1});
  var k = [];
  arr.map(function(val){
    if(k.indexOf(val[0]) == -1){
      k.push(val[0]);
      str = str + val[0] + val[1];
    }
  });
  str = str + 'key' + key;
  return md5.hex_md5(str);
}
module.exports = {
  sign: sign
}
